#pragma once
#include "..\Common\List.h"
#include "..\AutoPtr\AutoPtr.h"
#include "..\Common\DataBase.h"
#include "GrammarTree.h"

class CharClass
{
public:
	WCHAR Start;
	WCHAR End;
	int Index;
	GrammerType Type;

	CharClass() : Start(0),End(0),Index(-1),Type(gtChar){}

	BOOL operator ==(const CharClass& Class)const
	{
		if(Type != Class.Type) return FALSE;
		if(Start == Class.Start && End == Class.End) return TRUE;
		else return FALSE;
	}

	BOOL IsClass(WCHAR Data)
	{
		if(Type == gtChar || Type == gtTransferred || Type == gtOperator) return Data == Start;
		else if(Type == gtCharGroup) return Data >= Start && Data <= End;
		else if(Type == gtCharGroupNot) return Data < Start || Data > End;
		else if(Type == gtCharNot) return Data != Start;
		else return FALSE;
	}
};

class CharClassList
{
public:
	void DeleteChar(WCHAR Temp);
	int AddChar(WCHAR Temp,BOOL bNot = FALSE);
	int AddChars(WCHAR Temp1,WCHAR Temp2,BOOL bNot = FALSE);
	int AddOperator(WCHAR Temp);
	int AddTransferred(WCHAR Temp);
	NAutoPtr<CharClass> GetChar(WCHAR Temp,BOOL bNot = FALSE);
	NAutoPtr<CharClass> GetChars(WCHAR Temp1,WCHAR Temp2,BOOL bNot = FALSE);
	NAutoPtr<CharClass> GetOperator(WCHAR Temp);
	NAutoPtr<CharClass> GetTransferred(WCHAR Temp);
	BOOL InList(NAutoPtr<CharClass> Temp);
	NWString Print();
public:
	List<NAutoPtr<CharClass>> CharList;
};